package com.future.mapper;

import com.future.entity.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * <P>
 *
 * </p>
 *
 * @author yinhao
 * @version 1.0
 * @since 2024/9/11 16:35
 */
public interface UserMapperAnnotation {

    // 方式1,分步查询
    @Select("select * from mybatis_user where id = #{id}")
    @Results({
            @Result(property = "id", column = "id",id = true),
            @Result(property = "name", column = "name"),
            @Result(property = "petList", column = "id", many = @Many(select = "com.future.mapper.PetMapperAnnotation.queryPetByUserId"))
    })
    User queryUserById(Integer id);
}
